package com.learnyou.server.xingzuo.common.helper;

import com.baidu.aip.ocr.AipOcr;
import com.learnyou.server.xingzuo.common.config.AipOcrConfig;

import java.util.Objects;

public class AipOcrHelper {
    private static AipOcr aipOcrClient = null;

    private final static Object syncLock = new Object();

    private AipOcrHelper() {}

    public static AipOcr getAipOcrClient(AipOcrConfig config) {
        if (Objects.isNull(aipOcrClient)) {
            synchronized (syncLock) {
                if (Objects.isNull(aipOcrClient)) {
                    aipOcrClient = new AipOcr(config.getAppId(), config.getApiKey(), config.getSecretKey());
                }
            }
        }
        return aipOcrClient;
    }
}
